home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)F
/
(A)F1.ADF
/
chop3.msb
< prev
next >
Wrap
Text File
|
1986-06-08
|
2KB
|
83 lines
'Autochop--chops Xmodem-downloaded files by itself if hunkend can be
' found, else it asks user to specify file length.
' Based on Chop2.MSB and Fixobj.EXE. Created 3/21/86 by Charles Tyson.
CLEAR,50000&,4000
DEFLNG a-z
buff=22528
count=0
fm$="Bytes copied: #######"
hunkend$=CHR$(&H3)+CHR$(&HF2)
autochop:
LINE INPUT "Source file: ";infile$
PRINT
ON ERROR GOTO Errfile
OPEN infile$ AS 1 LEN=128
ON ERROR GOTO 0
FIELD 1,128 AS buff$
length=LOF(1)
recs=length\128
IF length-128*recs<>0 THEN PRINT infile$;" doesn't show signs of padding.":END
ON ERROR GOTO errrec
GET 1,recs
ON ERROR GOTO 0
testat=127:endat=0
WHILE (testat AND NOT endat)
endat=INSTR(testat,buff$,hunkend$)
testat=testat-1
WEND
IF endat<>0 THEN
total=128*(recs-1)+endat+1
PRINT "I think I'll chop this file from";length;"to";total;"bytes."
PRINT "Hit ESC if you disapprove, any other key if that's okay."
PRINT
IF INPUT$(1)<>CHR$(27) THEN chopit
ELSE
PRINT "Sorry, ";infile$;" can't be autochopped."
PRINT
END IF
Selfchop:
INPUT "Number of bytes to copy";total
PRINT
IF total>=length OR total<1 THEN PRINT "But ";infile$;" is only";length;"bytes long!":END
chopit:
LINE INPUT "Destination file: ";outfile$
PRINT
row=CSRLIN
CLOSE 1
ON ERROR GOTO Errfile
OPEN infile$ AS 1 LEN=buff
OPEN outfile$ FOR OUTPUT AS 2
ON ERROR GOTO 0
FIELD 1,buff AS buff$
PRINT USING fm$;count
Action:
WHILE count<total
ON ERROR GOTO errrec
GET 1
ON ERROR GOTO 0
count=count+buff
IF count<=total THEN
PRINT#2,buff$;
ELSE
PRINT#2,LEFT$(buff$,total+buff-count);
count=total
END IF
LOCATE row,1
PRINT USING fm$;count
WEND
END
Errfile:
CLOSE
PRINT "Oops, check those file names!"
RESUME autochop
errrec:
RESUME NEXT